/*lic*/
#ifndef __BSP_SPI_INIT_HELPER_H__
#define __BSP_SPI_INIT_HELPER_H__

#include "main.h"

typedef struct __Tag_Spi_Transport_Def {
	size_t spi_tx_size;
	size_t spi_rx_size;
	struct rt_semaphore spi_transport_sem;
	struct rt_mutex spi3_lock;
	uint8_t spi_status;
	uint8_t *spi_tx_buf;
	uint8_t *spi_rx_buf;
	CM_DMA_TypeDef *cm_dma_tx;
	uint8_t dma_ch_tx;
	CM_DMA_TypeDef *cm_dma_rx;
	uint8_t dma_ch_rx;
	CM_SPI_TypeDef *spi_cm;
}Spi_Transport_Def;


#define SPI_INITED (1 << 0)

extern Spi_Transport_Def spi3_obj;

//SPIx Config
void App_SPIxCfg(void);
// 初始化SPI3对象
rt_err_t Init_Spi3_Obj(void);

rt_err_t Spi_Start_Wait(Spi_Transport_Def* obj);
// 设置SPI速度
rt_err_t Spi_Set_Band(Spi_Transport_Def *obj, uint32_t u32BaudRatePrescaler);

void INT_SRC_DMA2_TC3_IrqCallback(void);
void INT_SRC_SPI3_SPII_IrqCallback(void);



#endif /* __BSP_SPI_INIT_HELPER_H__ */

/*eof*/
